#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import subprocess

print('nslookup')
p = subprocess.Popen('nslookup', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = p.communicate('set q=mx\npython.org\nexit\n'.encode('utf-8'))
print(output.decode('gbk'))
# print(output)
print('exit code:', p.returncode)
